<?php

    class Objects_gallery_model extends MY_Model
    {
        function __construct()
        {
            parent::__construct();
            $this->table = 'objects_gallery';
        }

        function find_object_gallery($object_id)
        {
            $q = "
            SELECT objects_gallery.*,
            gallery.path as path
            FROM objects_gallery
            LEFT JOIN gallery ON objects_gallery.gallery_ID = gallery.ID
            WHERE objects_gallery.objects_ID = $object_id
            ";
            
            $res = $this->db->query($q)->row_array();
            return $res;
        }
        
        function find_all_objects_galleries()
        {
            $q = "
            SELECT objects_gallery.*,
            gallery.path as path
            FROM objects_gallery
            LEFT JOIN gallery ON objects_gallery.gallery_ID = gallery.ID
            WHERE gallery.post_type is NULL
            ";
            
            $res = $this->db->query($q)->result_array();
            return $res;
        }
    }

?>
